import json

from requests.exceptions import RequestException
import requests

def get_one_page(url):
    headers = {
        "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9",
        "Accept-Encoding": "gzip, deflate",
        "Accept-Language": "zh-CN,zh;q=0.9",
        "Connection": "keep-alive",
        "Cookie": "FSSBBIl1UgzbN7N80S=.S.Q85IUMO.qUPqGaUCPv3j6ZIQPTqgr9Tql_GImc_MxzvQ6IaJfsNqpbrVic6nY; JSESSIONID1=AqqtcaEmzKJIF_I5_44mQHmOXFQaaQrPMCIg7Ih9xzsCZh39w3xR!-115340544; FSSBBIl1UgzbN7N80T=41bgw9qqP2wGAZsMqTeNmZqd0OWHN_9zPepLK0kHp7STGuLzjmWzSFRubwsf.D6qMN08_uX8EwNhq0WrFqXBHXsGB2Vc5P50Vw1.Sz8V1B5T6pVRzRYJOr2eu0s593Xrsgu5qOZZ8KWu92dxN6LfEw8Gvf1zuGA.QE68X.oe1EgY3zLWigMxjB3roojzGydwcnVEcDhuljOvpB3mWRvoOrqjM2xUxrq49CI13FnDr13fpGA3kaHchTX8TyX7zsKxEEUycqweCZnNFkVVLAyzQC_157kdIqto58G4I_GXpNMXlmT4sb5__dz3QA9rI1.bM8_uw6_SA6IqCdIPMnPFayJGY34dbjrcaVXN_0fwxcSQZT9jANQeewGj6KrabEOHoRuV",
        "Host": "www.fangdi.com.cn",
        "Upgrade-Insecure-Requests": "1",
        "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.122 Safari/537.36",
    }
    data = {
        'districtID': '',
        'dicRegionID': '',
        'stateID': '',
        'houseAreaID': '',
        'dicAvgpriceID': '',
        'dicPositionID': '',
        'houseTypeID': '',
        'address': '',
        'address': '',
        'projectName': '',
        'currentPage': '1',

    }
    try:
        s = requests.Session()
        text = s.post(url, headers=headers,data=data)
        data =text.text
        # data = json.loads(data)
        print(data)

    except RequestException:
        return None


def main():
    url = 'http://www.fangdi.com.cn/service/freshHouse/getHosueList.action'
    get_one_page(url)


if __name__ == "__main__":
    main()